package com.wnhz.work.yz.fragment.bathroomdetails;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ScrollView;

import com.meiqia.meiqiasdk.third.photoview.PhotoView;
import com.wnhz.work.yz.R;
import com.wnhz.work.yz.adapter.ParameterAdapter2;
import com.wnhz.work.yz.bean.BathroomDetail2Bean;
import com.wnhz.work.yz.view.NoScrollListView;

import org.xutils.x;

import java.util.ArrayList;
import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 * ---参数
 */
public class ParameterFragment2 extends Fragment implements View.OnClickListener {
    private View view;
    private NoScrollListView my_listView;
    private ParameterAdapter2 mAdapter;
    private ScrollView myScroll;
    private PhotoView iv_img_head;

    private List<BathroomDetail2Bean> beanList;
    private List<BathroomDetail2Bean.ParamEntity.DataEntity> dataList = new ArrayList<>();

    public void setBeanList(List<BathroomDetail2Bean> beanList) {
        this.beanList = beanList;
        for (int i = 0; i < beanList.size(); i++) {
            dataList = beanList.get(i).getParam().getData();
        }
        initView();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragment_parameter, container, false);
        initData();
        return view;
    }

    private void initData() {

    }

    private void initView() {
        iv_img_head = (PhotoView) view.findViewById(R.id.iv_img_head);

        my_listView = (NoScrollListView) view.findViewById(R.id.my_listView);
        myScroll = (ScrollView) view.findViewById(R.id.myScroll);
        for (int i = 0; i < beanList.size(); i++) {
            x.image().bind(iv_img_head, beanList.get(i).getParam().getCad_pic());
        }

        mAdapter = new ParameterAdapter2(getActivity(), dataList);
        my_listView.setAdapter(mAdapter);
        myScroll.smoothScrollTo(0, 0);


    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            default:
                break;
        }
    }

    public void scroll() {
        myScroll.smoothScrollTo(0, 0);
    }
}
